//
//  CYYCommentTableViewCell.m
//  LetsParty
//
//  Created by YG on 15/9/20.
//  Copyright (c) 2015年 LetsPartyTeam. All rights reserved.
//

#import "CYYCommentTableViewCell.h"

@interface CYYCommentTableViewCell()

- (void)initializeUserInterface;

@end

@implementation CYYCommentTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initializeUserInterface];
    }
    return self;
}

#pragma mark - responds event
- (void)repondsToSupportButton:(UIButton *)button{
    if (self.updateSupportDelegate && [self.updateSupportDelegate respondsToSelector:@selector(updateSupport:)]) {
         [self.updateSupportDelegate updateSupport:button];
    }
}

#pragma mark - private methods
-(void)initializeUserInterface{
    [self addSubview:self.userNameLabel];
    [self addSubview:self.tiemLabel];
    [self addSubview:self.commmenContentLabel];
//    self.commmenContentLabel.translatesAutoresizingMaskIntoConstraints = NO;
//    [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-40-[_commmenContentLabel]-10-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_commmenContentLabel)]];
    [self addSubview:self.supportButton];
    [self.supportButton addTarget:self action:@selector(repondsToSupportButton:) forControlEvents:UIControlEventTouchUpInside];
}

- (UILabel *)getLabelWith:(CGRect)frame{
    UILabel * lLabel = [[UILabel alloc]init];
    lLabel.frame = frame;
    lLabel.numberOfLines = 0;
    return lLabel;
}

#pragma mark - getter
- (UILabel *)userNameLabel{
    if (!_userNameLabel) {
        _userNameLabel = ({
            [self getLabelWith:DHFlexibleFrame(CGRectMake(5, 0, 200, 20), NO)];
        });
    }
    return _userNameLabel;
}

-(UILabel *)tiemLabel{
    if (!_tiemLabel) {
        _tiemLabel = ({
            [self getLabelWith:DHFlexibleFrame(CGRectMake(5, 20, 280, 10), NO)];
        });
    }
    return _tiemLabel;
}

-(UILabel *)commmenContentLabel{
    if (!_commmenContentLabel) {
        _commmenContentLabel = ({
            [self getLabelWith:DHFlexibleFrame(CGRectMake(40, 30, 260, 70), NO)];
        });
    }
    return _commmenContentLabel;
}

- (UIButton *)supportButton{
    if (!_supportButton) {
        _supportButton = ({
            UIButton * bButton = [UIButton buttonWithType:UIButtonTypeCustom];
            bButton.frame = DHFlexibleFrame(CGRectMake(250, 0, 50, 20),NO);
            bButton.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 30);
            bButton.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0);
            bButton;
        });
    }
    return _supportButton;
}





@end
